<?php
/**
 * api模块路由
 */

use think\facade\Route;

use \app\admin\middleware\OauthMiddleware;
use \app\admin\middleware\AllowCrossDomain;

Route::rule('/', function (Request $request) {
    return 'wrong request';
});
//验证token和权限
$oauthMiddleware = OauthMiddleware::class;
$allowCrossDomain = AllowCrossDomain::class;

//不验证
Route::group(function () {
    //TODO:后期需要删除
    Route::group('/Sample', function () {
        Route::get('/index', 'Sample/index');

    });

    //登录退出等
    Route::group('/Login', function () {
        Route::post('/login', 'Login/login');

    });
    //创建文档
    Route::group('/CreateSwaggerJson', function () {
        Route::get('/index', 'CreateSwaggerJson/index');
    });

});

//验证
Route::group(function () {
    Route::group('/Oauth', function () {
        Route::get('/index', 'Oauth/index');
    });

    Route::group('/Sample', function () {
        Route::get('/list', 'Sample/getList');
    });

    Route::group('/Login', function () {
        //获取登录信息
        Route::get('/detail', 'Login/detail');
        //获取权限
        Route::get('/Router', 'Login/getRouter');
    });

    //auth
    Route::group('/AuthGroup', function () {
        Route::get('/AuthGroupList', 'AuthGroup/getAuthGroupList');
        Route::get('/AuthGroupNoPageList', 'AuthGroup/getNoPageAuthGroupList');
        Route::post('/delAuthGroup', 'AuthGroup/deleteAuthGroup');
        Route::post('/AuthGroup', 'AuthGroup/addAuthGroup');
        Route::put('/AuthGroup', 'AuthGroup/updateAuthGroup');
    });

    //admin
    Route::group('/Admin', function () {
        Route::post('/adminList', 'Admin/adminList');
        Route::post('/adminAdd', 'Admin/adminAdd');
        Route::post('/adminEdit', 'Admin/adminEdit');
        Route::post('/adminDel', 'Admin/adminDel');
    });
    //menu
    Route::group('/Menu', function () {
        Route::post('/menuList', 'Menu/menuList');
        Route::post('/getRecursiveMenuList', 'Menu/getRecursiveMenuList');
        Route::post('/getRolesRecursiveMenuList', 'Menu/getRolesRecursiveMenuList');
        Route::post('/getMenuInfo', 'Menu/getMenuInfo');
        Route::post('/menuAdd', 'Menu/menuAdd');
        Route::post('/menuEdit', 'Menu/menuEdit');
        Route::post('/menuDel', 'Menu/menuDel');
    });
})->middleware([$allowCrossDomain, $oauthMiddleware]);


